//
//  VideoViewController.m
//  Tongcheng
//
//  Created by 邢广范 on 2017/4/3.
//  Copyright © 2017年 Tongcheng. All rights reserved.
//视频界面

#import "VideoViewController.h"
#import "DLTabedSlideView.h"
#import "VideoNewViewController.h"
#import "VideoHotViewController.h"
#import "BuyVIPViewController.h"

@interface VideoViewController ()<DLTabedSlideViewDelegate>

@property (weak, nonatomic) IBOutlet DLTabedSlideView *tabedSlideView;

@end

@implementation VideoViewController

- (void)setupView
{
    self.tabedSlideView.baseViewController = self;
    self.tabedSlideView.flag = @"3";
    self.tabedSlideView.tabItemNormalColor = [UIColor whiteColor];
    self.tabedSlideView.tabItemSelectedColor = RGB(0xF95880);
    
    self.tabedSlideView.delegate = self;
    self.tabedSlideView.tabNormalBackcolor = RGB(0xF95880);
    self.tabedSlideView.tabSelectBackcolor = [UIColor whiteColor];
    
    self.tabedSlideView.tabbarTrackColor = [UIColor clearColor];
    self.tabedSlideView.tabbarBottomSpacing = 3.0;
    
    DLTabedbarItem *item1 = [DLTabedbarItem itemWithTitle:@"最新" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""] normalColor:[UIColor blackColor] selectColor:[UIColor whiteColor]];
    DLTabedbarItem *item2 = [DLTabedbarItem itemWithTitle:@"最热" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""] normalColor:[UIColor blackColor] selectColor:[UIColor whiteColor]];
    
    self.tabedSlideView.tabbarItems = @[item1, item2];
    [self.tabedSlideView buildTabbar];
    self.tabedSlideView.selectedIndex = 0;
    
    UIButton *buyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    buyBtn.frame = CGRectMake(10, 30, 100, 26);
    [buyBtn setTitle:@"购买VIP" forState:UIControlStateNormal];
    buyBtn.titleLabel.font = [UIFont systemFontOfSize:20];
    [buyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    buyBtn.backgroundColor = [UIColor clearColor];
    [buyBtn addTarget:self action:@selector(clickBuy:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buyBtn];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupView];

    // Do any additional setup after loading the view from its nib.
}

- (NSInteger)numberOfTabsInDLTabedSlideView:(DLTabedSlideView *)sender{
    return 2;
}

- (UIViewController *)DLTabedSlideView:(DLTabedSlideView *)sender controllerAt:(NSInteger)index{
    switch (index) {
        case 0:
        {
            VideoNewViewController *ctrl = [[VideoNewViewController alloc] init];
            return ctrl;
        }
        case 1:
        {
            VideoHotViewController *ctrl = [[VideoHotViewController alloc] init];
            return ctrl;
        }
        default:
            return nil;
    }
}

- (void)clickBuy:(UIButton *)sender
{
    NSLog(@"go buyVIP");
    BuyVIPViewController *vip = [[BuyVIPViewController alloc] init];
    [self.navigationController pushViewController:vip animated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
